package character;

/**
 * Hit Points you have
 * 
 * @author bjo013
 * 
 */
public class HitPoints
{
	int maxHP;
	int bloodied;
	boolean isBloodied;
	int surgeValue;
	int surgesPrDay;
	int surgesUsed;
	private int currentHP;
	boolean used2ndWind;
	int tmpHP;

	/**
	 * Constructor HitPoints
	 * 
	 * @param maxHP
	 *            maximum hp
	 * @param surgesPrDay
	 *            number of surges pr day.
	 * @param used2ndWind
	 *            if 2nd wind is used.
	 */
	public HitPoints(int maxHP, int surgesPrDay)
	{
		this.maxHP = maxHP;
		currentHP = maxHP;
		bloodied = maxHP / 2;
		surgeValue = maxHP / 4;
		this.surgesPrDay = surgesPrDay;
		surgesUsed = 0;
		used2ndWind = false;
		tmpHP = 0;
	}

	/**
	 * returns what current hp is. Current hp is currentHP + tmpHP
	 * 
	 * @return currentHP + tmpHP
	 */
	public int getCurrentHP()
	{
		return currentHP + tmpHP;
	}

	/**
	 * Method for taking damage.
	 * 
	 * @param dmg
	 *            the amount of damage.
	 */
	public void takeDamage(int dmg)
	{
		currentHP = currentHP - dmg;
		if (getCurrentHP() <= bloodied)
		{
			isBloodied = true;
		}
	}

	/**
	 * sets the surges pr day.
	 * 
	 * @param i
	 *            number of surges pr day
	 */
	public void setSurgesPrDay(int i)
	{
		surgesPrDay = i;
	}

	/**
	 * gets the surges pr day.
	 * 
	 * @return number of surges pr day.
	 */
	public int getSurgesPrDay()
	{
		return surgesPrDay;
	}

	@Override
	public String toString()
	{
		String s = new String();
		s += "Max HP: " + maxHP + "\n";
		s += "Current HP: " + getCurrentHP() + "\n";
		s += "Temporary HP: " + tmpHP + "\n";
		s += "Bloodied at: " + bloodied + "\n";
		s += "Surge value: " + surgeValue + "\n";
		s += "Surges/day: " + surgesPrDay + "\n";
		s += "Surges used: " + surgesUsed + "\n";
		s += "Used 2nd Wind? " + used2ndWind;
		return s;
	}
}